package com.module.my.view

import android.view.ViewGroup
import com.module.app.base.BaseListActivity
import com.module.base.base.adapter.BaseAdapter
import com.module.my.R
import com.module.my.adapter.holder.ProblemHolder
import com.module.my.databinding.MyActivityProblemBinding
import com.module.my.model.ProblemViewModel

class ProblemActivity :
    BaseListActivity<ProblemViewModel, MyActivityProblemBinding, BaseAdapter>() {


    override fun bingViewModel() {
        mDatabind.vm = mViewModel
    }

    override fun createAdapter(): BaseAdapter {
        return object : BaseAdapter() {
            override fun onCreateDefaultViewHolder(
                parent: ViewGroup,
                viewType: Int
            ): ProblemHolder {
                return ProblemHolder(parent)
            }
        }
    }

    override fun initView() {
        super.initView()
        setMyTitle(R.string.my_problem_title)
        adapter.setStartPage(0)
        adapter.setPageSize(20)
    }

    override fun initData() {
        super.initData()
        reload()
    }

    override fun onListLoadPage(
        isPull: Boolean,
        isRefresh: Boolean,
        page_no: Int,
        page_size: Int
    ) {
        mViewModel.getData(isRefresh, page_no, page_size)
    }
}